package cn.argentoaskia.crm.config;

import org.springframework.stereotype.Component;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

// 以下代码没有特殊要求的情况下，通用写法
@Component
public class MvcConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowCredentials(true)
                .allowedMethods("POST", "GET", "PUT", "DELETE", "PATCH")
                .allowedOrigins("*")
                .allowedHeaders(CorsConfiguration.ALL);
    }
}
